package com.demo.controller_admin;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

public class BaseController {

	public static final int PAGE_SIZE=15;//layout表格每页大小
	
	@Value("${site.adminTemplatePrefix}")
	String adminTemplatePrefix;
	
	public Pageable getPageable(Integer page) {
		try {
			if(page==null || page<0 || page==0)	page=1;
		} catch (Exception e) {
			page = 1;
		}
		page-=1;
		Sort sort = new Sort(Sort.Direction.DESC, "id");
		Pageable pageable = PageRequest.of(page, PAGE_SIZE, sort);
		return pageable;
	}

}